using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;

namespace Gko.Utils
{
	[StructLayout(LayoutKind.Explicit)]
	internal struct NativeInterface
	{
		[FieldOffset(0)]
		private IntPtr virtualFunctionsTablePtr;

		internal NativeInterface(IntPtr pointer)
		{
			this.virtualFunctionsTablePtr = pointer;
		}

		internal IntPtr this[int index]
		{
			get
			{
				return Marshal.ReadIntPtr(this.virtualFunctionsTablePtr, index * IntPtr.Size);
			}
		}

		internal void SetMethod(int index, IntPtr pMethod)
		{
			Marshal.WriteIntPtr(this.virtualFunctionsTablePtr, index * IntPtr.Size, pMethod);
		}

		internal IntPtr VTable
		{
			get
			{
				return this.virtualFunctionsTablePtr;
			}
		}

		internal void AttachVTable(IntPtr ptr)
		{
			this.virtualFunctionsTablePtr = ptr;
		}
	}
}